<div class="Item hr">
    <div class="current">模型基本信息</div>
    <div class="fr"><a href="{:U('models/index')}" class="btn">返回模型列表</a></div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
    <tr>
        <th width="100">模型名称：</th>
        <td>{$model['name']}</td>
    </tr>
    <tr>
        <th width="100">数据表名：</th>
        <td>{$model['addtable']}</td>
    </tr>
    <tr>
        <th width="100">模型：</th>
        <td><if condition="$model['issystem'] == 1">系统<else/>自动</if></td>
    </tr>
</table>

<div class="Item hr">
    <div class="current">模型字段信息</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
    <thead>
        <tr>
            <td>字段名称</td>
            <td>字段标签</td>
            <td>数据类型</td>
            <td>字段类型</td>
            <td>字段操作</td>
        </tr>
    </thead>
    <tbody>
        <volist name="model['fields']" id="field" empty="$empty">
        <tr align="center">
            <td>{$field['name']}</td>
            <td>{$field['comment']}</td>
            <td>{$fieldtype[$field['type']]}</td>
            <td><eq name="field.autofield" value='1'>自动表单<else/>固化字段</eq></td>
            <td>
            [ <a href="{:U('Fields/edit', array('model_id' => $model['id'], 'field_id' => $field['id']))}">编辑</a> ] 
            [ <a href="{:U('Fields/delete', array('model_id' => $model['id'], 'field_id' => $field['id']))}" name="{$field['name']}" class="del">删除</a> ]
            </td>
        </tr>
        </volist>
    </tbody>
</table>
<div class="commonBtnArea" >
    <button class="btn submit" onclick="window.location.href='{:U('Fields/add', array('model_id' => $model['id']))}'">添加字段</button>
</div>

<script type="text/javascript">
$(function(){
    $(".del").click(function(){
        var url = $(this).attr("href");
        popup.confirm('你真的打算删除 <b>'+$(this).attr("name")+'</b> 吗?','温馨提示',function(action){
            if(action == 'ok'){
                $.getJSON(url, function(json) {
                    if (json.status) {
                        popup.success(json.info);
                        setTimeout(function(){
                            popup.close("asyncbox_success");
                            top.window.location.reload();
                        }, 2000);
                    } else {
                        popup.error(json.info);
                        setTimeout(function(){
                            popup.close("asyncbox_error");
                        }, 2000);
                    }
                });
            }
        });
        return false;
    });
});
</script>
